Read CSV into Dynamic object 路 Issue #729 路 JoshClose/CsvHelper 路 GitHub

您所在的位置:网站首页 csvreader object at Read CSV into Dynamic object 路 Issue #729 路 JoshClose/CsvHelper 路 GitHub

Read CSV into Dynamic object 路 Issue #729 路 JoshClose/CsvHelper 路 GitHub

#Read CSV into Dynamic object 路 Issue #729 路 JoshClose/CsvHelper 路 GitHub| 来源: 网络整理| 查看: 265

Hello,

I need to import from a CSV to a dynamic object. Once the object is populated by the CSV, I will use existing logic to store the values in the db. I've provided two CSV examples to illustrate what I'm trying to do.

Example 1:

Guid,SortOrder,title,description,url,color,icon f5bf7784-2413-46ad-a0bb-0d11a52b0fcc,10,Something,some things are cool,http://www.google.com,blue,calendar d51f6833-ced1-486e-bea6-2e3fe68b53bf,20,Another thing,other things are cooler,http://www.bing.com,yellow,search

Example 2:

Guid,SortOrder,name,jobtitle,picture a1bf7784-2413-46ad-a0bb-0d11a52b0fcc,10,John Doe,Boss,/path/to/john.jpg c31f6833-ced1-486e-bea6-2e3fe68b53bf,20,Bill Williamson,Underling,/path/to/bill.jpg

Both of these examples will be stored in the same database table with other identifying information that is not included in the CSV file (set programmatically). The "system" doesn't have a strongly typed class for either example, it's all dynamic.

So, I need to be able to import the CSV to a dynamic object which I will then parse to insert the data into the database.

I looked at Runtime Mapping but I'm getting an error when trying to do var customerMap = new DefaultCsvClassMap(). The error is "Using the generic type DefaultCsvClassMap requires 1 type arguments". I can do DefaultCsvClassMap() but then I'm not following which object should have the Keys property as the example shows with mapping.Keys.

If I've left anything out, let me know.

Thank you in advance, Joe



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3